package com.zp.self.module.level_5_设计模式.行为型模式.Ⅺ_解释器模式;

/**
 * @author ：by Zeng Peng
 * @date ：Created 2022/7/8 8:23
 * @description ：
 */
public class Plus extends AbstractExpression{
    private AbstractExpression left;
    private AbstractExpression right;

    public Plus(AbstractExpression left, AbstractExpression right) {
        this.left = left;
        this.right = right;
    }

    @Override
    public int interpret(Context context) {
        return left.interpret(context)+right.interpret(context);
    }

    @Override
    public String toString() {
        return "(" + left.toString() + " + " + right.toString() + ")";
    }
}
